//
//  NSURL+Tool.m
//  WordsRemindTool
//
//  Created by Duncan on 2021/8/17.
//

#import "NSURL+Tool.h"

@implementation NSURL (Tool)

///  输出路径
+ (NSURL *)exporterPathString:(NSString *)pathString filename:(NSString *)filename {
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    formatter.dateFormat = @"yyyyMMdd_HHmmssSSS";
    NSString *str = [formatter stringFromDate:[NSDate date]];
    NSString *fileName = [NSString stringWithFormat:@"PYB_%@.%@", str, filename];
    //这个是录制视频时存储到本地的video
    NSString *path = pathString;
    //判断文件夹是否存在，不存在就创建
    //创建附件存储目录
    if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
        [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
    }
    NSString *outputFilePath = [path stringByAppendingPathComponent:fileName];
    return [NSURL fileURLWithPath:outputFilePath];
}

@end
